//
//  PrayerTimeTable.m
//  prayertimes
//
//  Created by Serge Zalozniy on 6/9/13.
//  Copyright (c) 2013 Serge Zalozniy. All rights reserved.
//

#import "PrayerTimeTable.h"

@implementation PrayerTimeTable


#pragma mark - Instance initialization

-(id)init {
    self = [super init];
    if (!self) {
        return nil;
    }
    self.$_times = [NSMutableArray arrayWithCapacity:30];
    return self;
}


#pragma mark - Interface methods

-(void) setValue:(id)value forKey:(NSString *)key {
    if ([key isEqualToString:@"city"] || [key isEqualToString:@"$_city"]) {
        self.$_city = value;
        return ;
    }
    
    if ([key isEqualToString:@"country"] || [key isEqualToString:@"$_country"]) {
        self.$_country = value;
        return ;
    }
    
    if ([key isEqualToString:@"month"] || [key isEqualToString:@"$_month"]) {
        self.$_month = @([value integerValue]);
        return ;
    }
    
    if ([key isEqualToString:@"year"] || [key isEqualToString:@"$_yaer"]) {
        self.$_yaer = @([value integerValue]);
        return ;
    }
    
    if ([key isEqualToString:@"$_times"]) {
        self.$_times = value;
        return;
    }
    
    if ([[key substringToIndex:4] isEqualToString:@"date"]) {
        PrayerTime *object = [[[PrayerTime alloc] init] autorelease];
        [object setValuesForKeysWithDictionary:value];
        [self.$_times addObject:object];
    }
}


@end
